#!/usr/bin/env bash
#
# Creates a GitHub release and uploads all the executables
#
set -euf -o pipefail

version=$1
libname=$(basename $(dirname $(pwd)))
exe_base_name=cucumber-${libname}
add_args=$(find dist -type f -name "${exe_base_name}-*" | \
  # Replace newline with space
  tr '\n' ' ' | \
  # Remove trailing space
  sed -e 's/[[:space:]]*$//' | \
  # Insert ' -a ' between all files
  sed "s/[[:space:]]/ -a /g")
eval hub release create \
  --attach ${add_args} \
  --message "${exe_base_name}/v${version}" "${exe_base_name}/v${version}"
